package com.hdu.controller.collegeManagement;


import com.hdu.entity.Divide;
import com.hdu.entity.Subsection;
import com.hdu.pojo.PageBean;
import com.hdu.pojo.Result;
import com.hdu.service.ToolService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 工具实体类 前端控制器
 * </p>
 *
 * @author xiaobai
 * @since 2023-10-28
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@Api(tags = "工具管理接口")
@RequestMapping("/tool")
public class ToolController {

    private final ToolService toolService;

    @ApiOperation("查询分数对应位次")
    @GetMapping("/subsection")
    public Result<?> subsection(@RequestParam(defaultValue = "1") Integer page,
                             @RequestParam(defaultValue = "10") Integer limit,
                             Integer region, String year, Integer type, String score) {
        log.info("分页获取专业列表, 参数: {},{},{},{},{},{}", page, limit, region, year, type, score);
        PageBean<Subsection> pageBean = toolService.subsection(page, limit, region, year, type, score);
        return Result.success(pageBean);
    }

    @ApiOperation("一分一段查询")
    @GetMapping("/subsection/chart")
    public Result<?> chart(Integer region, String year, Integer type) {
        log.info("分页获取专业列表, 参数: {},{},{}",  region, year, type);
        return Result.success(toolService.chart(region, year, type));
    }

    @ApiOperation("查询录取批次")
    @GetMapping("/divide")
    public Result<?> divide(@RequestParam(defaultValue = "1") Integer page,
                             @RequestParam(defaultValue = "10") Integer limit,
                             Integer region, String year, Integer type) {
        log.info("分页获取录取批次, 参数: {},{},{},{},{}", page, limit, region, year, type);
        PageBean<Divide> pageBean = toolService.divide(page, limit, region, year, type);
        return Result.success(pageBean);
    }
}
